<?php

namespace app\model;

use think\Model;
use think\facade\Db;

class Site extends Model
{
    protected $name = 'Site';
    protected $table = 'site_config';
    protected $connection = 'mysql';
    static public function get($item = "")
    {
        if ($item == "") {
            return "";
        } elseif ($item == "banner") {
            return Db::connect()->table('site_banner')->select()->toArray();
        } elseif ($item == "navitems") {
            return Db::connect()->table('site_nav')->select()->toArray();
        } elseif ($item == "footer_list") {
            $x = Db::connect()->table('site_footer')->select()->toArray();
            foreach ($x as $k => $v) {
                $x[$k]['links'] = json_decode($v['links'], true);
            }
            return $x;
        }

        return Site::where('name', $item)->find()->value;
    }
}
